package com.hisense.hiioc.hismartplate.entity.table.typehandler;

import com.hisense.hiioc.hismartplate.entity.table.enumdefine.ClientClickType;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @Author: almo
 * @Date: 2018/12/18 上午11:17
 * @Version 1.0
 */
public class ClientClickTypeHandler implements TypeHandler<ClientClickType> {

    @Override
    public void setParameter(PreparedStatement preparedStatement, int i, ClientClickType clientClickType, JdbcType jdbcType) throws SQLException {
        preparedStatement.setInt(i, clientClickType.getIndex());
    }

    @Override
    public ClientClickType getResult(ResultSet resultSet, String s) throws SQLException {
        return ClientClickType.intOf(resultSet.getInt(s));
    }

    @Override
    public ClientClickType getResult(ResultSet resultSet, int i) throws SQLException {
        return ClientClickType.intOf(resultSet.getInt(i));
    }

    @Override
    public ClientClickType getResult(CallableStatement callableStatement, int i) throws SQLException {
        return ClientClickType.intOf(callableStatement.getInt(i));
    }

}
